<!--
 * @description: 登录页
 * @Date: 2023-01-28 12:13:39
 * @example: 父应用
 * @params:
-->
<template>
  <div>
    <iframe
      src="http://kai.anrookie.cn/"
      frameborder="0"
      title="123654"
      class="iframe"
    />
  </div>   
</template>
<script setup lang="ts">
import { nextTick, onBeforeUnmount } from "vue";


import { useRouter } from "vue-router";
import useMainStore from "@/stores/user";

const store = useMainStore(); 
const router = useRouter();
  
const handleMessage = (event: any): void => {
  const { data } = event;

  if (data?.cmd === "send_token" && data?.params.token) {
    console.log("username======",data.params.username)
    window.sessionStorage.setItem("useremail",data.params.username)
    window.sessionStorage.setItem("token",data.params.token)
    store.$state.Userinfo = data.params;
    router.push("/applist/home");
    return;
  }
  // console.log("子页面传过来的值", event);
};

nextTick(() => {
  window.addEventListener("message", handleMessage);
});
onBeforeUnmount(() => {
  window.removeEventListener("message", handleMessage);
});
</script>
<style scoped lang="less">
.logo {
  height: 6em;
  padding: 1.5em;
  will-change: filter;
}
.iframe {
  width: 100%;
  height: 100vh;
}
.logo:hover {
  filter: drop-shadow(0 0 2em #646cffaa);
}

.logo.vue:hover {
  filter: drop-shadow(0 0 2em #42b883aa);
}
</style>
